//
//  FriendsterTableViewCell.m
//  BaChat
//
//  Created by dllo on 16/6/18.
//  Copyright © 2016年 刘洋. All rights reserved.
//

#import "FriendsterTableViewCell.h"

@interface FriendsterTableViewCell ()
@property (retain, nonatomic) IBOutlet UIImageView *icon;
@property (retain, nonatomic) IBOutlet UILabel *name;

@property (retain, nonatomic) IBOutlet UIImageView *vip;

@property (retain, nonatomic) IBOutlet UILabel *Text;
@property (retain, nonatomic) IBOutlet UIImageView *picture;

@end

@implementation FriendsterTableViewCell

+ (instancetype)dequeueReusableCellWithTableView:(UITableView *)tableView
{
    FriendsterTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([FriendsterTableViewCell class])];
    return cell;
}

- (void)setStatuses:(Statuses *)statuses
{
    if (_statuses != statuses) {
        [_statuses release];
        _statuses = [statuses retain];
        self.picture.backgroundColor = [UIColor redColor];
        //    _statuses = statuses;
        if (!_statuses.isVip) {
            _vip.hidden = YES;
            self.name.textColor = [UIColor blackColor];
        } else {
            _vip.hidden = NO;
            self.name.textColor = [UIColor orangeColor];
        }
        if (!_statuses.picture) {
            self.picture.hidden = YES;
        } else {
            self.picture.hidden = NO;
            self.picture.image = [UIImage imageNamed:_statuses.picture];
        }
        self.name.text = statuses.name;
        self.Text.text = statuses.text;
        self.icon.image = [UIImage imageNamed:_statuses.icon];
        
        [self layoutIfNeeded];
        if (self.picture.hidden) {
            _statuses.height = CGRectGetMaxY(self.Text.frame) + 10;
        } else {
            _statuses.height = CGRectGetMaxY(self.picture.frame) + 10;
        }

    }
    
    
}


- (void)awakeFromNib {
    // Initialization code
    self.Text.preferredMaxLayoutWidth = [[UIScreen mainScreen] bounds].size.width - 20;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [_icon release];
    [_name release];
    [_vip release];
    [_Text release];
    [_picture release];
    [_statuses release];
    [super dealloc];
}
@end
